<!-- 
	Form for the transaction page
	
	@author mrduongnv@gmail.com  
-->

<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>

<c:choose>
	<c:when test="${empty newTransactionForm.transactionDetails}">
		<tr>
			<td colspan="12"><spring:message code="sp.transactionform.label.atpresenttherearenotransactiontext" />.<br />
			<spring:message code="sp.transactionform.label.ifyouwereexpectingsometransactiontext" /></td>
		</tr>
	</c:when>
	<c:otherwise>

		<table border=0 cellpadding=0 cellspacing=0>

			<tr>
				<td><b><spring:message code="sp.transactionform.label.approvepayment" /></b></td>

			</tr>
		</table>
		
		<form:form id="main" commandName="newTransactionForm" action="confirm_transaction.htm" method="post">
			<form:hidden path="providerId" />
			<table width=98% class="formTable">
				<tr class="formHeader">
					<td align="left"><b><spring:message code="sp.transactionform.label.viewnewtransactions" /></b></td>

				</tr>
				<tr>
					<td>
					<table width="100%">
						<tr>
							<th><spring:message code="sp.transactionform.label.ser" /></th>
							<th><spring:message code="sp.transactionform.label.ssn" /></th>
							<th><spring:message code="sp.transactionform.label.customername" /></th>
							<th><spring:message code="sp.transactionform.label.amountreceived" /></th>
							<th><spring:message code="sp.transactionform.label.svcfee" /></th>
							<th><spring:message code="sp.transactionform.label.selffee" /></th>
							<th><spring:message code="sp.transactionform.label.taxprepfee" /></th>
							<th><spring:message code="sp.transactionform.label.electronicpreparationfee" /></th>
							<th><spring:message code="sp.transactionform.label.electronicfillingfee" /></th>
							<th><spring:message code="sp.transactionform.label.servicebureaufee" /></th>
							<th><spring:message code="sp.transactionform.label.federalbankproductfee" /></th>
							<th><spring:message code="sp.transactionform.label.stateproductbankfee" /></th>
							<th><spring:message code="sp.transactionform.label.chooselabels" /><br />
								<c:choose>
									<c:when test="${newTransactionForm.approved == true}">
										<form:input id="customLabelName1" maxlength="18" path="customLabelName1" disabled="true" />
									</c:when>
									<c:otherwise>
										<form:input id="customLabelName1" maxlength="18" path="customLabelName1"  
											onkeyup="enableLabels('customLabelName1', 'customLabelValue1')" />
									</c:otherwise>									
								</c:choose>									
							</th>
 								
							<th><spring:message code="sp.transactionform.label.chooselabels" /><br />
								<c:choose>
									<c:when test="${newTransactionForm.approved == true}">
										<form:input id="customLabelName2" maxlength="18" path="customLabelName2" disabled="true" />
									</c:when>
									<c:otherwise>
										<form:input id="customLabelName2" maxlength="18" path="customLabelName2"  
											onkeyup="enableLabels('customLabelName2', 'customLabelValue2')" />
									</c:otherwise>									
								</c:choose>							
							</th>
							<th><spring:message code="sp.transactionform.label.select" />
								<c:if test="${newTransactionForm.approved != true}">
									<a href="transaction_form.jsp#" onclick="return ch_select(true);">All</a>
									<a href="transaction_form.jsp#" onclick="return ch_select(false);">None</a>
								</c:if>									
							</th>
						</tr>

						<tbody>
							<c:forEach var="newTransaction" items="${newTransactionForm.transactionDetails}" varStatus="i">
								<c:choose>
									<c:when test="${newTransaction.errorText eq ''}">
										<tr>
									</c:when>
									<c:otherwise>
										<tr>
											<td colspan="14" style="color: #ff0000">${newTransaction.errorText}</td>
										</tr>
										<tr style="background-color: yellow">
									</c:otherwise>
								</c:choose>
									<form:hidden path="transactionDetails[${i.index}].id" />
									<td>${i.index+1}</td>
									<td>${newTransaction.customerSSN}</td>
									<td>${newTransaction.customerName}</td>
									<td>${newTransaction.amount}</td>
									<td>$${newTransaction.serviceFee}</td>
									<td><form:input disabled="${newTransaction.approved or newTransactionForm.approved}" cssClass="selfFee" id="selfFee"
										path="transactionDetails[${i.index}].selfFee" size="11" title="SELF Fee"/></td>
									<td><form:input disabled="${newTransaction.approved or newTransactionForm.approved}" cssClass="taxPrepFee" 
										path="transactionDetails[${i.index}].taxPrepFee" size="11" title="Tax Prep Fee"/></td>
									<td><form:input disabled="${newTransaction.approved or newTransactionForm.approved}" cssClass="electronicPrepFee" 
										path="transactionDetails[${i.index}].electronicPrepFee" size="11" title="Electronic Preparation Fee" /></td>
									<td><form:input disabled="${newTransaction.approved or newTransactionForm.approved}" cssClass="electronicFillingFee" 
										path="transactionDetails[${i.index}].electronicFillingFee" size="11" title="Electronic Filling Fee"/></td>
									<td><form:input disabled="${newTransaction.approved or newTransactionForm.approved}" cssClass="serviceBureauFee" 
										path="transactionDetails[${i.index}].serviceBureauFee" size="11" title="Service Bureau Fee" /></td>
									<td>
										<div style="border: 1px none #ff0000; width: 60%" >									
											<form:select cssStyle="width: 100%;" path="transactionDetails[${i.index}].fedBankProductFee" 
												cssClass="fedBankProductFee" disabled="${newTransaction.approved or newTransactionForm.approved}" 
													title="Federal Bank Product Fee">
												<form:option value=""></form:option>
												<c:forEach begin="1" var="idx1" end="50" step="1">
													<form:option value="${idx1}">$${idx1}</form:option>
												</c:forEach>
											</form:select>
										</div>
									</td>
									<td>
										<div style="border: 1px none #ff0000; width: 60%" >
											<form:select cssStyle="width: 100%;" path="transactionDetails[${i.index}].stateProductFee" cssClass="stateProductFee"
												disabled="${newTransaction.approved or newTransactionForm.approved}" 
													title="State Product Bank Fee">
												<form:option value=""></form:option>
												<c:forEach begin="1" var="idx2" end="50" step="1">
													<form:option value="${idx2}">$${idx2}</form:option>
												</c:forEach>
											</form:select>
										</div>										
									</td>
									<td><form:input cssClass="customLabelValue1" path="transactionDetails[${i.index}].customLabel1" size="11" 
										disabled="true" title="Custom label 1" /></td>
									<td><form:input cssClass="customLabelValue2" path="transactionDetails[${i.index}].customLabel2" size="11" 
										disabled="true" title="Custom label 2" /></td>
									<td>
										<input type="hidden" name="_isSelected${i.index}" id="_isSelected${i.index}" value="${newTransaction.checked}"/>
										<c:choose>
											<c:when test="${newTransaction.approved or newTransactionForm.approved}">
												<input type="checkbox" disabled="disabled" class="isSelected" 
													name="isSelected${i.index}" id="isSelected${i.index}" value="${newTransaction.checked}" 
													<c:if test="${newTransaction.checked}">checked = "checked"</c:if>
													onchange="document.getElementById('_isSelected${i.index}').value = this.checked"/>
											</c:when>
											<c:otherwise>
												<input type="checkbox" class="isSelected" 
													name="isSelected${i.index}" id="isSelected${i.index}" value="${newTransaction.checked}" 
													<c:if test="${newTransaction.checked}">checked = "checked"</c:if> 
													onchange="document.getElementById('_isSelected${i.index}').value = this.checked"/>
											</c:otherwise>
										</c:choose>
									</td>
								</tr>
								<c:choose>
									<c:when test="${newTransaction.errorText eq ''}">
										<tr>
									</c:when>
									<c:otherwise>
										<tr style="background-color: yellow">
									</c:otherwise>
								</c:choose>
									<td colspan="3" />
									<td colspan="12">
										<c:set var="transactionIndex" value="${i.index}" />
										<div id="payeesList${i.index}">
											<%@include file="/WEB-INF/jsp/serviceprovider/transaction/transaction_payees.jsp"%>
										</div>
									</td>								
								</tr>
								<tr></tr>
							</c:forEach>
						</tbody>
					</table>
					</td>
				</tr>

				<tr>
					<th colspan="12"><spring:message code="sp.transactionform.label.messageoftheday" />:</th>
				</tr>
				<c:choose>
					<c:when test="${newTransactionForm.approved != true }">
						<tr>
							<th colspan="12" class="green"><spring:message code="sp.transactionform.label.clickonapprove" />.</th>
						</tr>
					</c:when>
					<c:otherwise>
						<tr>				
							<th colspan="12" class="green"><spring:message code="sp.transactionform.label.clickonbacktotransactionapproval" />.</th>					
						</tr>
						<tr>				
							<th colspan="12" class="green"><spring:message code="sp.transactionform.label.clickonconfirm" />.</th>					
						</tr>
					</c:otherwise>
				</c:choose>			
			</table>
			<tr>
				<c:if test="${not empty newTransactionForm.transactionDetails and newTransactionForm.approved == false}">
					<td>
						<input type="button" class='ui-button ui-state-default ui-corner-all' id="approveTransactionBtn" name="approveTransactionBtn" value="<spring:message code="sp.transactionform.button.approve" />" 
							onclick="javascript: approveTransaction();return false;"/>
					</td>
				</c:if>
				<c:if test="${not empty newTransactionForm.transactionDetails and newTransactionForm.approved}">
					<td>
						<input type="button" class='ui-button ui-state-default ui-corner-all' name="backToEdit" value="<spring:message code="sp.transactionform.button.backtotransactionapproval" />" 
							onclick="javascript: backToTransactionApproval();return false;"/>
					</td>
				</c:if>
				<c:if test="${newTransactionForm.approved == true}">
					<td>
						<input type="button" class='ui-button ui-state-default ui-corner-all' name="confirmTransactionsBtn" value="<spring:message code="sp.transactionform.button.confirm" />" 
							onclick="javascript: confirmTransactions();return false;"/>
					</td>
				</c:if>
			</tr>
		</form:form>
	</c:otherwise>
</c:choose>
